//
//  HZBasicInfoController.m
//  MyDoctor
//
//  Created by chen on 16/5/5.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZBasicInfoController.h"

@interface HZBasicInfoController () <UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) UITableView *infoTableView;

@end

@implementation HZBasicInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    
    
    
}

#pragma mark -
#pragma mark  设置UI
-(void)setupUI{
    
    self.title = @"个人信息修改";
    
    self.infoTableView = [[UITableView alloc]init];
    
    self.infoTableView.backgroundColor = [UIColor whiteColor];
    
    //设置代理
    self.infoTableView.dataSource = self;
    self.infoTableView.delegate = self;
    
    //注册cell
    [self.infoTableView registerClass:[HZBasicInfoCell class] forCellReuseIdentifier:@"cell"];
    
    [self.view addSubview: self.infoTableView];
    
    //设置约束
    [self.infoTableView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.leading.bottom.trailing.equalTo(self.view);
        
    }];
    
    UIView * headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 140)];
    
    
    self.infoTableView.tableHeaderView = headView;
    
    //实例化headView里面需要的控件
    //头像
    UIImageView * headImage = [[UIImageView alloc]init];
    
    headImage.image = [UIImage imageNamed:@"name"];
    
    //姓名
    UIImageView * nameImage = [[UIImageView alloc]init];
    nameImage.image = [UIImage imageNamed:@"0"];
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.text = @"龙霸天";
    nameLabel.font = [UIFont systemFontOfSize:13];
    nameLabel.textColor = [UIColor grayColor];
    
    
    //ID
    UIImageView * IDImage = [[UIImageView alloc]init];
    IDImage.image = [UIImage imageNamed:@"idCard"];
    UILabel *IDLabel = [[UILabel alloc]init];
    IDLabel.text = @"5201314";
    IDLabel.font = [UIFont systemFontOfSize:13];
    IDLabel.textColor = [UIColor grayColor];
    
    
    
    
    //phone
    UIImageView * phoneImage = [[UIImageView alloc]init];
    phoneImage.image = [UIImage imageNamed:@"phone"];
    UILabel *phoneLabel = [[UILabel alloc]init];
    phoneLabel.text = @"74110";
    phoneLabel.font = [UIFont systemFontOfSize:13];
    phoneLabel.textColor = [UIColor grayColor];
    
    
    
    
    //添加控件
    [headView addSubview:headImage];
    [headView addSubview:nameImage];
    [headView addSubview:IDImage];
    [headView addSubview:phoneImage];
    [headView addSubview:nameLabel];
    [headView addSubview:IDLabel];
    [headView addSubview:phoneLabel];
    
    
    //设置约束
    //头像
    [headImage makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.equalTo(headView).offset(30);
        make.height.equalTo(80);
        make.width.equalTo(80);
    }];
    
    //姓名
    [nameImage makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headImage);
        make.leading.equalTo(headImage.trailing).offset(20);
        make.height.equalTo(16);
        make.width.equalTo(12);
        
    }];
    
    [nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(nameImage);
        make.leading.equalTo(nameImage.trailing).offset(10);
    }];
    
    
    
    
    //ID
    [IDImage makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameImage.bottom).equalTo(16);
        make.leading.equalTo(headImage.trailing).offset(20);
        make.height.equalTo(16);
        make.width.equalTo(12);
        
    }];
    
    [IDLabel makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(IDImage);
        make.leading.equalTo(IDImage.trailing).offset(10);
    }];
    
    
    
    //phone
    [phoneImage makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(headImage);
        make.leading.equalTo(headImage.trailing).offset(20);
        make.height.equalTo(16);
        make.width.equalTo(12);
        
    }];
    
    [phoneLabel makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(phoneImage);
        make.leading.equalTo(phoneImage.trailing).offset(10);
    }];
    
    
}



#pragma mark -
#pragma mark  数据源方法和代理方法

#pragma mark -
#pragma mark  设置行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
    
}

#pragma mark -
#pragma mark  设置cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HZBasicInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (indexPath.row == 0) {
        cell.textLabel.text = @"身高";
        
    }else if(indexPath.row == 1){
        cell.textLabel.text = @"体重";
        
    }else{
        cell.textLabel.text = @"省份";
    }
    
    return cell;
}

#pragma mark -
#pragma mark  点击cell调用的方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击cell");
    //弹出一个半透明的View
    UIView *coverView = [[UIView alloc]init];
    coverView.alpha = 1;
    
    coverView.backgroundColor = [UIColor blueColor];
    
    [tableView addSubview:coverView];
    
    //设置约束
    [coverView makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.bottom.trailing.equalTo(self.view);
    }];
    
    
    
    
}







@end
